#!/bin/sh
#
# radvd:       Starts the hiawatha web server
#
# Version:      @(#) /etc/rc.d/init.d/hiawatha 1.0
#
# chkconfig: 345 60 10
# description: Hiawatha web server
# processname: hiawatha
# config: /etc/hiawatha/httpd.conf

### BEGIN INIT INFO
# Provides: hiawatha httpd
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Short-Description: Hiawatha web server
# Description: Hiawatha web server
### END INIT INFO
# Stolen from radvd script

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/hiawatha ] ; then
	. /etc/sysconfig/hiawatha
fi

if [ -f /opt/hiawatha/usr/sbin/hiawatha ] ; then
	hiawatha="/opt/hiawatha/usr/sbin/hiawatha"
else
	hiawatha="/usr/sbin/hiawatha"
fi

config="/etc/hiawatha"

RETVAL=0

if [ -f /etc/sysconfig/custom.hiawatha ] ; then
	. /etc/sysconfig/custom.hiawatha
fi

start() {
	echo -n $"Starting Hiawatha web server: "
	daemon $hiawatha -c $config
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/hiawatha
	return $RETVAL
}

stop() {
	echo -n $"Stopping Hiawatha web server: "
	killproc hiawatha
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/hiawatha
	echo
	return $RETVAL
}

restart() {
	stop
	start
}       

reload() {
	echo -n $"Reloading configuration: "
	killproc hiawatha -USR1
	RETVAL=$?
	echo
	return $RETVAL
}       

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		status hiawatha
		;;
	restart)
		restart
		;;
	reload)
		reload
		;;
	condrestart)
		if [ -f /var/lock/subsys/hiawatha ]; then
			stop
			start
		fi
		;;
	*)
	echo $"Usage: hiawatha {start|stop|status|restart|reload|condrestart}"
	exit 1
esac

exit $RETVAL